/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package avenue;

import java.awt.Window;
import java.awt.event.WindowEvent;
import avenue.Utils;
import javax.swing.JDialog;
import javax.swing.JFrame;


public class MyWindowEvent extends WindowEvent {

    private static JFrame JFrame(Window window) {
        throw new UnsupportedOperationException("Not yet implemented");
    }
    public boolean exitAndSave;

    public MyWindowEvent(Window source, int id, boolean exitAndSave) {
        super(source, id);
        this.exitAndSave = exitAndSave;
    }

    public static boolean isExitAndSave(WindowEvent arg0) {
        String uc = "";
         
        if (arg0.getWindow() instanceof JFrame) {
            uc = ((JFrame) arg0.getWindow()).getTitle();
        } else if (arg0.getWindow() instanceof JDialog) {
            uc = ((JDialog) arg0.getWindow()).getTitle();
        }
               
        if (arg0 instanceof MyWindowEvent) {
            if (((MyWindowEvent) arg0).exitAndSave) {
                Utils.mainForm.log(uc + ": Αποθήκευση");
            } else {
                Utils.mainForm.log(uc + ": Aκύρωση");
            }
            return ((MyWindowEvent) arg0).exitAndSave;
        } else {
            Utils.mainForm.log(uc + ": Aκύρωση με το πλήκτρο Χ");
            return false;
        }
    }
}
